package onlineCodingQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/v3/onlineCodingQuizzes/1")
                , consumer(regex("/api/v3/onlineCodingQuizzes/\\d+")))) {
            queryParameters {
                parameter("status", "")
            }
        }
    }
    response {
        status(200)
        body("""
        {
            "id":1,
            "description":"description",
            "evaluateScript":"evaluateScript",
            "templateRepository":"templateRepository",
            "makerId":1,
            "onlineCodingName":"onlineCodingName",
            "language":"language",
            "answerPath":"answerPath",
            "stackId":1,
            "answerDescription":"answerDescription",
            "definitionRepo":"definitionRepo",
            "available":true,
            "status":2,
            "buildNumber":1,
            "quizGroupId":1,
            "remark":"remark",
        }
        """)
        bodyMatchers {
            jsonPath('$', byType())
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.description', byRegex("[\\s\\S]+"))
            jsonPath('$.evaluateScript', byRegex("[\\s\\S]+"))
            jsonPath('$.templateRepository', byRegex("[\\s\\S]+"))
            jsonPath('$.makerId', byRegex(number()))
            jsonPath('$.onlineCodingName', byRegex("[\\s\\S]+"))
            jsonPath('$.language', byRegex("[\\s\\S]+"))
            jsonPath('$.answerPath', byRegex("[\\s\\S]+"))
            jsonPath('$.stackId', byRegex(number()))
            jsonPath('$.answerDescription', byRegex("[\\s\\S]+"))
            jsonPath('$.definitionRepo', byRegex("[\\s\\S]+"))
            jsonPath('$.available', byRegex(anyBoolean()))
            jsonPath('$.status', byRegex(number()))
            jsonPath('$.buildNumber', byRegex(number()))
            jsonPath('$.quizGroupId', byRegex(number()))
            jsonPath('$.remark', byRegex("[\\s\\S]+"))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
